package com.lingqi.util;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class DBUtil {
    private static final DataSource dataSource;

    static {
        MysqlDataSource db = new MysqlDataSource();
        String url = "jdbc:mysql://localhost:3306/lib?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai";
        db.setUrl(url);
        db.setUser("root");
        db.setPassword("123456");

        dataSource = db;
    }

    public static Connection connection() throws SQLException{
        return dataSource.getConnection();
    }
}
